<extend name="Public/base" />
<block name="body">
  <div class="main-title cf">
    <h2>新增商品</h2>
  </div>
  
  <!-- 标签页导航 -->
  <div class="tab-wrap">
    <div class="tab-content"> 
      <!-- 表单 -->
      <form id="form" action="{:U('update')}" method="post" class="form-horizontal doc-modal-form">
        <!-- 基础 -->
        <div id="tab1" class="tab-pane in tab1">
          <div class="form-item cf">
            <label class="item-label">商品名称</label>
            <div class="controls">
              <input type="text" class="text " name="title" value="{$info.title}">
            </div>
          </div>
          <div class="form-item">
            <label class="item-label">价格<span class="check-tips">（人民币的价格）</span></label>
            <div class="controls">
              <input type="text" class="text input-mid" name="price" value="{$info.price}" >
            </div>
          </div>
          <div class="form-item">
            <label class="item-label">库存<span class="check-tips">（只能填写数字）</span></label>
            <div class="controls">
              <input type="text" class="text input-mid" name="stock" value="{$info.stock}" >
            </div>
          </div>
          <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
          <div class="form-item">
            <label class="item-label">封面图片</label>
            <div class="controls">
              <input type="file" id="upload_picture_cover_id">
              <input name="cover_id" type="hidden" id="cover_id_cover_id" value="{$info['cover_id']}"/>
              <div class="upload-img-box">
                <notempty name="info['cover_id']">
                  <div class="upload-pre-item"><img src="{$info['cover_id']|get_cover='path'}"/></div>
                </notempty>
              </div>
            </div>
            <script type="text/javascript">
                //上传图片
                /* 初始化上传插件 */
                $("#upload_picture_cover_id").uploadify({
                    "height"          : 30,
                    "swf"             : "__STATIC__/uploadify/uploadify.swf",
                    "fileObjName"     : "download",
                    "buttonText"      : "上传图片",
                    "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id(), 'mid'=>26))}",
                    "width"           : 120,
                    'removeTimeout'	  : 1,
                    'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                    "onUploadSuccess" : uploadPicturecover_id,
                'onFallback' : function() {
                    alert('未检测到兼容版本的Flash.');
                }
                });
                function uploadPicturecover_id(file, data){
                    var data = $.parseJSON(data);
                    var src = '';
                    if(data.status){
                        $("#cover_id_cover_id").val(data.id);
                        src = data.url || '__ROOT__' + data.path
                        $("#cover_id_cover_id").parent().find('.upload-img-box').html(
                                '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                        );
                    } else {
                        updateAlert(data.info);
                        setTimeout(function(){
                            $('#top-alert').find('button').click();
                            $(that).removeClass('disabled').prop('disabled',false);
                        },1500);
                    }
                }
            </script> 
          </div>
          <div class="form-item cf">
            <label class="item-label">商品描述<span class="check-tips"></span></label>
            <div class="controls">
              <label class="textarea input-large">
                <textarea name="description">{$info.description}</textarea>
              </label>
            </div>
          </div>
        </div>
        <!-- 按钮 -->
        <div class="form-item cf">
          <label class="item-label"></label>
          <div class="controls edit_sort_btn">
          	<input type="hidden" name="id" value="{$info.id|default=0}" />
            <button class="btn submit-btn ajax-post no-refresh" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
          </div>
        </div>
      </form>
    </div>
  </div>
</block>
<block name="script"> 
  <script type="text/javascript" charset="utf-8">
    //导航高亮
    highlight_subnav('{:U('Goods/index')}');
</script> 
</block>
